//
//  MineViewController.m
//  Pacific_Computer
//
//  Created by 范琦 on 14-12-17.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "MineViewController.h"
#import "UIColor+AddColor.h"
#import "RegisterViewController.h"
#import "SetViewController.h"
#import "UIImageView+WebCache.h"
#import "Reard_ViewController.h"
#import "BrowseViewController.h"
#import "SDImageCache.h"
#import "AppDelegate.h"
#import "WeiboSDK.h"
#import "WBHttpRequest.h"
#import <MessageUI/MessageUI.h>

@interface MineViewController () <WBHttpRequestDelegate,UIAlertViewDelegate,MFMailComposeViewControllerDelegate>

@property (nonatomic,retain) UIView *nigView;

@property (nonatomic,retain) UILabel *attenNum;
@property (nonatomic,retain) UILabel *beanNum;
@property (nonatomic,retain) UILabel *wbNum;
@property (nonatomic,retain) UILabel *nameLabel;
@property (nonatomic,retain) UIImageView *NameImage;
@property (nonatomic,assign) BOOL swButton;

@end

@implementation MineViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center addObserver:self selector:@selector(receiveNotifica:) name:@"tamenlaile" object:nil];
        
        NSNotificationCenter *center2 = [NSNotificationCenter defaultCenter];
        [center2 addObserver:self selector:@selector(receiveNotifica2:) name:@"tamenpaole" object:nil];
        
        
        
    }
    return self;
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [_nigView release];
    [_attenNum release];
    [_beanNum release];
    [_wbNum release];
    [_nameLabel release];
    [_NameImage release];
    [super dealloc];
}

- (void)receiveNotifica:(NSNotification *)center
{
    UIView *view = (UIView *)[self.view viewWithTag:100];
    UIView *view2 = (UIView *)[self.view viewWithTag:102];
    view.hidden = YES;
    view2.hidden = NO;
    
    NSMutableDictionary *dic = [center.userInfo objectForKey:@"key"];
    
    self.nameLabel.text = [dic objectForKey:@"name"];
    
    NSURL *url = [NSURL URLWithString:[dic objectForKey:@"profile_image_url"]];
    [self.NameImage setImageWithURL:url];
    
    
    NSNumber *att = [dic objectForKey:@"friends_count"];
    NSNumber *bean = [dic objectForKey:@"friends_count"];
    NSNumber *wb = [dic objectForKey:@"statuses_count"];


    self.attenNum.text = [att description];
    self.beanNum.text = [bean description];
    self.wbNum.text = [wb description];
    self.swButton = YES;

}


- (void)receiveNotifica2:(NSNotification *)center
{
    UIView *view = (UIView *)[self.view viewWithTag:100];
    UIView *view2 = (UIView *)[self.view viewWithTag:102];
    view.hidden = NO;
    view2.hidden = YES;
    
    self.attenNum.text = @"";
    self.beanNum.text = @"";
    self.wbNum.text = @"";
    self.swButton = NO;
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor huiseColor];
    //self.navigationController.navigationBar.barTintColor = [UIColor hongse];
    self.navigationItem.title = @"个人中心";

    self.navigationController.navigationBar.tintColor  = [UIColor hongse];
//    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
//    
//    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigation_bar_background.png"] forBarMetrics:UIBarMetricsDefault];
//    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
//    self.navigationController.navigationBar.shadowImage = [UIImage imageNamed:@"navigation_bar_background.png"];
    
    
    
    UIView *bossView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height *9.5 / 100, self.view.bounds.size.width, self.view.bounds.size.height * 32 / 100)];
    bossView.tag = 100;
    [self.view addSubview:bossView];
    [bossView release];
    
    UIImageView * boss1Image = [[UIImageView alloc] initWithFrame:bossView.bounds];
    UIImage *boimage = [UIImage imageNamed:@"meijing3.png"];
    boss1Image.image = boimage;
    boss1Image.backgroundColor = [UIColor redColor];
    [bossView addSubview:boss1Image];
    [boss1Image release];
    
//    UIImageView * nameImage = [[UIImageView alloc] initWithFrame:bossView.bounds];
//    nameImage.backgroundColor = [UIColor redColor];
//    nameImage.image = boimage;
//    [nameView addSubview:bossImage];
//    [nameImage release];
    
    
    UIImageView *userImage = [[UIImageView alloc] initWithFrame:CGRectMake(bossView.bounds.size.width * 2 / 5, bossView.bounds.size.height / 4, bossView.bounds.size.width * 18 / 100, bossView.bounds.size.height * 32.5 / 100)];
    userImage.backgroundColor = [UIColor whiteColor];
    UIImage *usimage = [UIImage imageNamed:@"User.png"];
    
    userImage.backgroundColor = [UIColor huiseColor];
    userImage.layer.cornerRadius = userImage.frame.size.width / 2;
    [bossView addSubview:userImage];
    [userImage release];
    
    UIImageView *sImage = [[UIImageView alloc] initWithFrame:CGRectMake(userImage.bounds.size.width * 5.7 / 100, userImage.bounds.size.height * 5.7 / 100, userImage.bounds.size.width - (userImage.bounds.size.width * 11.4 /100), userImage.bounds.size.height - (userImage.bounds.size.height * 11.4 /100))];
    sImage.backgroundColor = [UIColor whiteColor];
    sImage.layer.cornerRadius = (userImage.bounds.size.height - (userImage.bounds.size.height * 11.4 /100)) / 2;
    
    UIImageView *UserImage = [[UIImageView alloc] initWithFrame:CGRectMake(sImage.bounds.size.width *15 / 100, sImage.bounds.size.height * 11.2 / 100, sImage.bounds.size.width - (sImage.bounds.size.width * 32.2 / 100), sImage.bounds.size.height - (sImage.bounds.size.height * 32.2 / 100))];
    [sImage addSubview:UserImage];
    UserImage.image = usimage;
    UserImage.layer.cornerRadius = (sImage.bounds.size.height - (sImage.bounds.size.height * 32.2 / 100))/2;
    [UserImage release];
    [userImage addSubview:sImage];
    [sImage release];
    
    UITapGestureRecognizer *tapOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOneAction:)];
    [bossView addGestureRecognizer:tapOne];
    [tapOne release];
    //=============================================
    UIView *nameView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height *9.5 / 100, self.view.bounds.size.width, self.view.bounds.size.height * 32 / 100)];
    nameView.tag = 102;
    [self.view addSubview:nameView];
    [nameView release];
    
    UIImageView * nameImage = [[UIImageView alloc] initWithFrame:bossView.bounds];
    nameImage.backgroundColor = [UIColor redColor];
    nameImage.image = boimage;
    [nameView addSubview:nameImage];
    [nameImage release];
//

    
    
    UIImageView *oneImage = [[UIImageView alloc] initWithFrame:CGRectMake(nameView.bounds.size.width * 2 / 5, nameView.bounds.size.height / 8, nameView.bounds.size.width * 18 / 100, nameView.bounds.size.height * 32.5 / 100)];
    oneImage.backgroundColor = [UIColor huiseColor];
    oneImage.layer.cornerRadius = oneImage.frame.size.width / 2;
    [nameView addSubview:oneImage];
    [oneImage release];

    
    
    UIImageView *akbImage = [[UIImageView alloc] initWithFrame:CGRectMake(oneImage.bounds.size.width * 5.7 / 100, oneImage.bounds.size.height * 5.7 / 100, oneImage.bounds.size.width - (oneImage.bounds.size.width * 11.4 /100), oneImage.bounds.size.height - (oneImage.bounds.size.height * 11.4 /100))];
    akbImage.backgroundColor = [UIColor whiteColor];
    akbImage.layer.cornerRadius = (oneImage.bounds.size.height - (oneImage.bounds.size.height * 11.4 /100)) / 2;
    [oneImage addSubview:akbImage];
    [akbImage release];
    
//
    self.NameImage = [[UIImageView alloc] initWithFrame:CGRectMake(oneImage.bounds.size.width * 5.7 / 100, oneImage.bounds.size.height * 5.7 / 100, oneImage.bounds.size.width - (oneImage.bounds.size.width * 11.4 /100), oneImage.bounds.size.height - (oneImage.bounds.size.height * 11.4 /100))];
    [oneImage addSubview:self.NameImage];
   self.NameImage.layer.cornerRadius = (oneImage.bounds.size.height - (oneImage.bounds.size.height * 11.4 /100)) / 2;

    self.NameImage.clipsToBounds = YES;
    [_NameImage release];
    
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameView.bounds.size.width * 11 / 100, nameView.bounds.size.height * 6.5 / 14, nameView.bounds.size.width * 73.33 / 100, nameView.bounds.size.height * 13.95 / 100)];
    
    
    self.nameLabel.text = @"瀚海烟云";
    self.nameLabel.font = [UIFont fontWithName:@"Arial-BoldItalicMT" size:16];
    self.nameLabel.textAlignment = 1;
    //nameLabel.backgroundColor = [UIColor redColor];
    [nameView addSubview:self.nameLabel];
    [_nameLabel release];
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(nameView.bounds.size.width * 36.53 / 100, nameView.bounds.size.height * 6.5 / 10, 1, nameView.bounds.size.height *2.5 / 11)];
    view1.backgroundColor = [UIColor shenhuiseColor];
    [nameView addSubview:view1];
    
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(nameView.bounds.size.width * 64 / 100, nameView.bounds.size.height * 6.5 / 10, 1, nameView.bounds.size.height *2.5 / 11)];
    view2.backgroundColor = [UIColor shenhuiseColor];
    [nameView addSubview:view2];
    
    UILabel *attenLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameView.bounds.size.width *19 / 100, nameView.bounds.size.height * 7.65 / 10, nameView.bounds.size.width * 13.33 / 100, nameView.bounds.size.height * 11.62 / 100)];
    attenLabel.text = @"关注";
    //attenLabel.backgroundColor = [UIColor redColor];
    attenLabel.textAlignment = 1;
    [nameView addSubview:attenLabel];
    [attenLabel release];
    
    
    UILabel *beanLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameView.bounds.size.width *43.33 / 100, nameView.bounds.size.height * 7.65 / 10, nameView.bounds.size.width * 13.33 / 100, nameView.bounds.size.height * 11.62 / 100)];
    beanLabel.text = @"粉丝";
    beanLabel.textAlignment = 1;
    beanLabel.font = [UIFont systemFontOfSize:16];
    [nameView addSubview:beanLabel];
    [beanLabel release];
    
    UILabel *wbLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameView.bounds.size.width *69 / 100, nameView.bounds.size.height * 7.65 / 10, nameView.bounds.size.width * 13.33 / 100, nameView.bounds.size.height * 11.62 / 100)];
    wbLabel.text = @"微博";
    wbLabel.textAlignment = 1;
    wbLabel.font = [UIFont systemFontOfSize:16];
    [nameView addSubview:wbLabel];
    [wbLabel release];
    
    
    self.attenNum = [[UILabel alloc] initWithFrame:CGRectMake(nameView.bounds.size.width *19 / 100, nameView.bounds.size.height * 6.5 / 10, nameView.bounds.size.width * 13.33 / 100, nameView.bounds.size.height * 11.62 / 100)];
    self.attenNum.textAlignment = 1;
    self.attenNum.text = @"66";
    [nameView addSubview:self.attenNum];
    [_attenNum release];
    
    self.beanNum = [[UILabel alloc] initWithFrame:CGRectMake(nameView.bounds.size.width *43.33 / 100, nameView.bounds.size.height * 6.5 / 10, nameView.bounds.size.width * 13.33 / 100, nameView.bounds.size.height * 11.62 / 100)];
    self.beanNum.textAlignment = 1;
    self.beanNum.text = @"66";
    [nameView addSubview:self.beanNum];
    [_beanNum release];
    
    
    self.wbNum = [[UILabel alloc] initWithFrame:CGRectMake(nameView.bounds.size.width * 69 / 100, nameView.bounds.size.height * 6.5 / 10, nameView.bounds.size.width * 13.33 / 100, nameView.bounds.size.height * 11.62 / 100)];
    self.wbNum.textAlignment = 1;
    self.wbNum.text = @"66";
    [nameView addSubview:self.wbNum];
    [_wbNum release];
    
    nameView.hidden = YES;
    
    
    //=================================================
    //登入状态
    UILabel *ennerLabel = [[UILabel alloc] initWithFrame:CGRectMake(bossView.bounds.size.width * 26.6 / 100, bossView.bounds.size.height * 60.4 / 100, bossView.bounds.size.width * 46.6 / 100, bossView.bounds.size.height * 11.6 / 100)];
    ennerLabel.text = @"登入后，分享更快捷";
    
    ennerLabel.textAlignment = 1;
    ennerLabel.font = [UIFont systemFontOfSize:15];
    ennerLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [bossView addSubview:ennerLabel];
    [ennerLabel release];
    
    //============================================
    //我的收藏
    UIView *collectView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height * 43.5 / 100, self.view.bounds.size.width, self.view.bounds.size.height * 7.49 / 100)];
    collectView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:collectView];
    [collectView release];
    
    UIImageView *collectImage = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 5.33 / 100, collectView.bounds.size.height * 3 / 11, collectView.bounds.size.width * 6.66 / 100, collectView.bounds.size.height  / 2)];
    UIImage *collImage = [UIImage imageNamed:@"shoucan.png"];
    collectImage.image = collImage;
    [collectView addSubview:collectImage];
    [collectImage release];
    
    UILabel *collectLabel = [[UILabel alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 18.6 / 100, collectView.bounds.size.height / 5, collectView.bounds.size.width * 20 / 100, collectView.bounds.size.height * 3 /5)];
    collectLabel.text = @"最近浏览";
    collectLabel.font = [UIFont systemFontOfSize:16];
    [collectView addSubview:collectLabel];
    [collectLabel release];
    
    UIImageView *imageCollect = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 90.6 / 100, collectView.bounds.size.height * 3 / 10, collectView.bounds.size.width / 25, collectView.bounds.size.height * 44 / 100)];
    UIImage *rightImage = [UIImage imageNamed:@"xiangyou.png"];
    imageCollect.image = rightImage;
    [collectView addSubview:imageCollect];
    
    UITapGestureRecognizer * tapSet1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(browse:)];
    [collectView addGestureRecognizer:tapSet1];
    [tapSet1 release];
    
    //============================================
    //清空缓存
    UIView *browseView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height * 51.32 / 100, self.view.bounds.size.width, self.view.bounds.size.height * 7.49 / 100)];
    browseView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:browseView];
    [browseView release];
    
    UIImageView *browseImage = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 5.33 / 100, collectView.bounds.size.height * 3 / 11, collectView.bounds.size.width * 6.66 / 100, collectView.bounds.size.height  / 2)];
    UIImage *browImage = [UIImage imageNamed:@"qk.png"];
    browseImage.image = browImage;
    [browseView addSubview:browseImage];
    [browseImage release];
    
    UILabel *browseLabel = [[UILabel alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 18.6 / 100, collectView.bounds.size.height / 5, collectView.bounds.size.width * 20 / 100, collectView.bounds.size.height * 3 /5)];
    browseLabel.text = @"清空缓存";
    browseLabel.font = [UIFont systemFontOfSize:16];
    [browseView addSubview:browseLabel];
    [browseLabel release];
    
    UIImageView *imageBrowse = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 90.6 / 100, collectView.bounds.size.height * 3 / 10, collectView.bounds.size.width / 25, collectView.bounds.size.height * 44 / 100)];
    imageBrowse.image = rightImage;
    [browseView addSubview:imageBrowse];
    UITapGestureRecognizer *browTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(browTapAction:)];
    [browseView addGestureRecognizer:browTap];
    [browTap release];
    
    
    
    
    //夜间模式
    UIView *hightView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height * 60.8 / 100, self.view.bounds.size.width, self.view.bounds.size.height * 7.49 / 100)];
    hightView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:hightView];
    [hightView release];
    
    UIImageView *hightImage = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 5.33 / 100, collectView.bounds.size.height * 3 / 10, collectView.bounds.size.width * 6 / 100, collectView.bounds.size.height  / 2 - 2)];
    UIImage *higImage = [UIImage imageNamed:@"yejian.png"];
    hightImage.image = higImage;
    [hightView addSubview:hightImage];
    [hightImage release];
    
    UILabel *hightLabel = [[UILabel alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 18.6 / 100, collectView.bounds.size.height / 6, collectView.bounds.size.width * 20 / 100, collectView.bounds.size.height * 3 /5)];
    hightLabel.text = @"夜间模式";
    hightLabel.font = [UIFont systemFontOfSize:16];
    [hightView addSubview:hightLabel];
    [hightLabel release];
    
    UISwitch *Switch = [[UISwitch alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 83 / 100, collectView.bounds.size.height /5, collectView.bounds.size.width / 25, collectView.bounds.size.height * 3 / 5)];
    Switch.onTintColor = [UIColor hongse];
    [hightView addSubview:Switch];
    Switch.on = YES;
    [Switch setOn:NO];
    [Switch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
    
    [Switch release];

    
    //============================================
    
    
    //设置
    UIView *setView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height * 70.3 / 100, self.view.bounds.size.width, self.view.bounds.size.height * 7.49 / 100)];
    setView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:setView];
    [setView release];
    
    UIImageView *setImage = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 5.33 / 100, collectView.bounds.size.height * 3 / 11, collectView.bounds.size.width * 6 / 100, collectView.bounds.size.height  / 2 - 2)];
    UIImage *seImage = [UIImage imageNamed:@"tuichu.png"];
    setImage.image = seImage;
    [setView addSubview:setImage];
    [setImage release];
    
    UILabel *setLabel = [[UILabel alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 18.6 / 100, collectView.bounds.size.height / 5, collectView.bounds.size.width * 20 / 100, collectView.bounds.size.height * 3 /5)];
    setLabel.text = @"注销";
    setLabel.font = [UIFont systemFontOfSize:16];
    [setView addSubview:setLabel];
    [setLabel release];
    
    UIImageView *imageSet = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 90.6 / 100, collectView.bounds.size.height * 3 / 10, collectView.bounds.size.width / 25, collectView.bounds.size.height * 44 / 100)];
    imageSet.image = rightImage;
    [setView addSubview:imageSet];
    
    UITapGestureRecognizer * tapSet = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapSetAction:)];
    [setView addGestureRecognizer:tapSet];
    [tapSet release];

    
    
    
    //============================================
    //关于我们
    UIView *regardView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height * 79.8 / 100, self.view.bounds.size.width, self.view.bounds.size.height * 7.49 / 100)];
    regardView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:regardView];
    [regardView release];
    
    UIImageView *regardImage = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 5.33 / 100, collectView.bounds.size.height * 3 / 11, collectView.bounds.size.width * 6.66 / 100, collectView.bounds.size.height  / 2)];
    UIImage *regaImage = [UIImage imageNamed:@"fangkui.png"];
    regardImage.image = regaImage;
    [regardView addSubview:regardImage];
    [regardImage release];
    
    UILabel *regardLabel = [[UILabel alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 18.6 / 100, collectView.bounds.size.height / 5, collectView.bounds.size.width * 20 / 100, collectView.bounds.size.height * 3 /5)];
    regardLabel.text = @"意见反馈";
    regardLabel.font = [UIFont systemFontOfSize:16];
    [regardView addSubview:regardLabel];
    [regardLabel release];
    
    UIImageView *imageRegard = [[UIImageView alloc] initWithFrame:CGRectMake(collectView.bounds.size.width * 90.6 / 100, collectView.bounds.size.height * 3 / 10, collectView.bounds.size.width / 25, collectView.bounds.size.height * 44 / 100)];
    imageRegard.image = rightImage;
    [regardView addSubview:imageRegard];
    
    UITapGestureRecognizer *regardTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(regardTapAction:)];
    [regardView addGestureRecognizer:regardTap];
    [regardTap release];
    
    
    self.nigView = [[UIView alloc] initWithFrame:self.view.bounds];
    self.nigView.userInteractionEnabled = NO;
    self.nigView.hidden = YES;
    self.nigView.backgroundColor = [UIColor blackColor];
    self.nigView.alpha = 0.5;
    [self.tabBarController.view addSubview:self.nigView];
    [_nigView release];
    
    

}

//清空缓存
- (void)browTapAction:(UITapGestureRecognizer *)tap
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请问是否清空所有缓存" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定" ,nil];
    alert.tag = 999;
    [alert show];
    [alert release];
    
    

}


- (void)regardTapAction:(UITapGestureRecognizer *)tap
{
    if ([MFMailComposeViewController canSendMail]) {
        
        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        picker.mailComposeDelegate = self;
        
        [picker setSubject:@"感谢您的意见反馈,祝您生活愉快!"];

        NSArray *toRecipients = [NSArray arrayWithObject:@"lc93727930@163.com"];
 
        [picker setToRecipients:toRecipients];

        [self presentViewController:picker animated:YES completion:^{
            
        }];
        
    }
    
    
    
//    Reard_ViewController *reard = [[Reard_ViewController alloc] init];
//    [self.navigationController pushViewController:reard animated:YES];
//    [reard release];
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    
    [self dismissViewControllerAnimated:YES completion:^{
        
//                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"邮件发送成功，谢谢您的反馈" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
//                [alertView show];
//                [alertView release];
    }];
}


- (void)tapOneAction:(UITapGestureRecognizer *)tap
{
    RegisterViewController *regiSter = [[RegisterViewController alloc]init];
    [self.navigationController pushViewController:regiSter animated:YES];

}


- (void)tapSetAction:(UITapGestureRecognizer *)tap
{
    
    
//    SetViewController *set = [[SetViewController alloc] init];
//    set.swButton = self.swButton;
//    [self.navigationController pushViewController:set animated:YES];
//    [set release];

    if (self.swButton == YES) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"请问是否要注销" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定" ,nil];
            [alert show];
            [alert release];
            alert.tag = 998;

    }else if (self.swButton == NO){
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"未登入，无法注销" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
    
    
}
- (void)browse:(UITapGestureRecognizer *)tap
{
    BrowseViewController *browse = [[BrowseViewController alloc]init];
    [self.navigationController pushViewController:browse animated:YES];
    [browse release];

}

- (void)switchAction:(id)sender
{
    
    UISwitch *Switch = (UISwitch *)sender;
    BOOL button = [Switch isOn];
    if (button) {
        NSLog(@"是");
        
        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value",@"key", nil];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"heiyejianglin" object:@"香皂" userInfo: dic];
    }else {
        NSLog(@"否");
        
        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value",@"key", nil];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"limingjianglin" object:@"香皂" userInfo: dic];
        
    }
}


- (void)buttonClciked:(UIButton *)button
{
//    //1.UIView动画
//    [UIView animateWithDuration:0.5 animations:^{
    
//        button.backgroundColor = [UIColor huiseColor];
//        button.backgroundColor = [UIColor whiteColor];
//        
//    }];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    float num = [[SDImageCache sharedImageCache] checkTmpSize];
    if (alertView.tag == 999) {
        switch (buttonIndex) {
            case 1:
                
                [[SDImageCache sharedImageCache] clearDisk];
                NSString * str = [NSString stringWithFormat:@"缓存清除成功, 大小为%.2fMB",num];
                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:str delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
                [alertView show];
                [alertView release];
                break;
                
            default:
                break;
        }
    }else if (alertView.tag == 998){
        switch (buttonIndex) {
            case 1:
                
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
                    [WeiboSDK logOutWithToken:myDelegate.wbtoken delegate:self withTag:@"111"];
                    
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"注销成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
                    [alert show];
                    [alert release];
                    self.swButton = NO;
                    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value",@"key", nil];
                    [[NSNotificationCenter defaultCenter]postNotificationName:@"tamenpaole" object:@"香皂" userInfo: dic];
                });
                break;
                
            default:
                break;
        }
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
